<?php if (!defined('THINK_PATH')) exit();?><!-- 社区筛选条件 超级管理员组 与 普通管理员组-->
    <script>
        //城市
        var allCity = eval('<?php echo ($e_allCity); ?>');
        var allArea = eval('<?php echo ($e_allArea); ?>');
    </script>
    城市：
    <select id="qname" name="citycode" autocomplete="off"> 
        <option value="-1">请选择城市</option>
        <?php if(is_array($allCity)): foreach($allCity as $key=>$vo): ?><option value="<?php echo ($vo["code"]); ?>" <?php if($citycode == $vo['code']): ?>selected="selected"<?php endif; ?> ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; ?>
    </select> 
分区：
    <select id="jname" name="area_id" autocomplete="off"> 
        <option value="-1">请选择街道</option>
        <?php if(is_array($allArea)): foreach($allArea as $key=>$vo): ?><option value="<?php echo ($vo["code"]); ?>" <?php if($area_id == $vo['code']): ?>selected="selected"<?php endif; ?> ><?php echo ($vo["name"]); ?></option><?php endforeach; endif; ?>
    </select>    
   <script>
   $(document).ready(function(){
	    // 初始时的控件的值
	    var areaId = $("#qname").val();
	    var streetId = $("#jname").val();
	    var html = "";

	    function ref_component_base(curr_change_id, title, each_var, b_id, curr_id, html_val, op_attr_id, op_attr_name){
	        if (curr_change_id != '-1') {
	            // 区域
	            html = "<option value='-1'>" + title + "</option>";
	            $.each(each_var, function(a,b){
	                if (b[b_id] == curr_change_id) {
	                    if ( curr_id != '-1' && curr_id == b[op_attr_id] ) {
	                        html += "<option value='" + b[op_attr_id] + "' selected='selected'>" + b[op_attr_name] + "</option>"
	                    } else {
	                        html += "<option value='" + b[op_attr_id] + "'>" + b[op_attr_name] + "</option>"
	                    }
	                };
	            });
	            $("#" + html_val).html(html);
	        } else {
	            html = "<option value='-1'>" + title + "</option>";
	            $("#" + html_val).html(html);
	        }
	    }

	    function ref_component(){
	        ref_component_base(areaId, "请选择分区", allArea, 'citycode', streetId, "jname", 'code', 'name');
	    }

	    ref_component();
	    

	    // 区域有变化
	    $("#qname").bind("change",function(){
	        areaId = $("#qname").val();
	        streetId = '-1';
	        shequId = '-1';
	        ref_component();
	    });

	});

   </script>